package com.winit.openapi.sms.common;

import java.io.IOException;
import java.io.InputStream;

import org.apache.commons.io.IOUtils;
import org.apache.http.client.fluent.Request;
import org.apache.http.entity.ContentType;
import org.springframework.core.io.FileSystemResource;
import org.springframework.core.io.Resource;

public class SmsRestAPI {

    public static void invoice(String openapiUrl,String filePath) {
        Resource resource = new FileSystemResource(filePath);
        try {
            InputStream in = resource.getInputStream();
            String json = IOUtils.toString(in);
            Request.Post(openapiUrl)
                .bodyString(json, ContentType.APPLICATION_JSON)
                .execute()
                .returnContent()
                .asString();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}
